

import axios from 'axios'
import Nprogress from 'nprogress'
import 'nprogress/nprogress.css'

const service  = axios.create({
    baseURL:'mock',
    timeout:20000
})

// 请求拦截器
service.interceptors.request.use(
    (config)=>{
        Nprogress.start()
        return config
    }
)

// 响应拦截器

service.interceptors.response.use(
    (response)=>{
        Nprogress.done()
        return response.data
    },
    (error)=>{
        Nprogress.done()
        alert('请求错误'  + error.message || '未知错误')

        return new Promise(()=>{})
    }
)


export default service
